<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>我的评论</title>


    <!-- Expand styles -->
    <link href="../css/app/app.css" rel="stylesheet">
    <link href="../css/app/default.css" rel="stylesheet">
    <link href="../css/mui/mui.css" rel="stylesheet">


    <!-- Custom styles for this template -->s
    <!-- <link href="../css/iOS/mobile/mobile.css" rel="stylesheet"> -->
</head>

<body>

    <!-- header -->
    <div id="pullrefresh" class="mui-content mui-scroll-wrapper">
        <div class="mui-content">
            <div class="trade-list">

            </div>
        </div>
    </div>


    <script src="../js/dsbridge.js"></script>
    <script src="../js/jquery.js"></script>
    <script src="../js/mui/mui.js"></script>
    <script src="../js/mui/mui.picker.min.js"></script>
    <script src="../js/layer.js"></script>
    <script src="../js/app/app-base.js"></script>
    <script src="../js/app/app-url.js"></script>
    <script src="../js/app/app-ajax.js"></script>

    <script>

        var page = 1;
        var limit = 10;
        var index = 0;
        var all_data = new Array();
        $(document).ready(function () {

            mui.init({
                pullRefresh: {
                    container: '#pullrefresh',
                    down: {
                        auto: true, // 首次进入自动加载
                        callback: pulldownRefresh
                    },
                    up: {
                        contentrefresh: '正在加载...',
                        callback: pullupRefresh
                    }
                }
            });
        });

        /**
         * 下拉刷新具体业务实现
         */
        function pulldownRefresh() {
            page = 1;
            var data = {
                userAccId: getUserId(),
                page: page,
                limit: limit
            }
           
            getServerData(url_getMy_evaluationVideosList, data);
        }

        /**
         * 上拉加载具体业务实现
         */
        function pullupRefresh() {
            page++;
            var data = {
                userAccId: getUserId(),
                page: page,
                limit: limit
            }
            getServerData(url_getMy_evaluationVideosList, data);
        }


        function getServerDataSuccess(url, data) {

            // var plist = new Array();
            var list = data.data;
            var html_data = "";
            if (page == 1) {
                index = 0;
                all_data.length = 0;
            }
            if (list.length > 0) {
                for (var i = 0; i < list.length; i++) {
                    all_data.push(list[i]);
                    var commHeadPortrait = list[i].commentPerson.headPortrait;
                    var personHeadPortrait = list[i].agriVideoInfo.person.headPortrait;
                    html_data += '<div class="widget-default margin-b-10 widget-body">' +
                        '<div class="display-flex personInfo" id ="' + list[i].commentPerson.userAccId + '">' +
                        '<img class="farm-head" src="' + ((commHeadPortrait == '' || commHeadPortrait == null) ? '../img/headimg.png' : showSmallImg(commHeadPortrait)) + '" alt="">' +
                        '<div class="display-flex flex-column justify-content-between margin-l-10 padding-t-3">' +
                        '<span class="elli1 black font-16 font-weight">' + list[i].commentPerson.userName + '</span>' +
                        '<span class="gray font-12">' + list[i].createAt + '</span>' +
                        '</div>' +
                        '</div>' +
                        '<p class="font-15 black elli2 padding-t-10 videoDetail" dId="' + index + '">' +
                        list[i].content + '</p>' +
                        '<div class="display-flex">' +
                        '<div class="left-img videoDetail" dId="' + index + '">' +

                        '<img class="img" src="' + showSmallImg(list[i].agriVideoInfo.coverImg) + '"  width="100%" height="65" alt="">' +

                        '</div>' +
                        '<div class="display-flex flex-column margin-l-10 justify-content-between">' +
                        '<p class="font-13 gray font-weight elli2 no-margin videoDetail"  dId="' + index + '">' + list[i].agriVideoInfo.title + '</p>' +
                        '<div class="display-flex align-items-center personInfo" id ="' + list[i].agriVideoInfo.person.userAccId + '">' +
                        '<img class="littlt-icon" src="' + ((personHeadPortrait == '' || personHeadPortrait == null) ? '../img/headimg.png' : showSmallImg(personHeadPortrait)) + '" alt="">' +
                        '<span class="font-15 gray margin-l-10">' + list[i].agriVideoInfo.person.userName + '</span>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '</div>';

                    index++;
                }
                ;
            }
            if (page == 1) {
                mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
                if (list.length > 0) {
                    mui('#pullrefresh').pullRefresh().refresh(true);
                }
                $(".trade-list").html(html_data);
            } else {
                $(".trade-list").append(html_data);
                mui('#pullrefresh').pullRefresh().endPullupToRefresh(list.length != limit);
            }


        }


        //详情
        mui(".trade-list").on('tap', '.videoDetail', function () {
            var detailIndex = $(this).attr("dId");
            log(all_data[detailIndex].agriVideoInfo.id)
            if (all_data[detailIndex].agriVideoInfo.type == 'AGRT_TECH_VIDEO') {
                //农技视频
                localStorage.setItem("video-detail-id", all_data[detailIndex].agriVideoInfo.id);
                dsBridge.call("goAgriTechVideoDetail", "");
            } else if (all_data[detailIndex].agriVideoInfo.type == 'SMALL_VIDEO') {
                //小视频
                dsBridge.call("smallVideo", all_data[detailIndex].agriVideoInfo.id);
            }
        });


        function getServerDataFailed(url, data) {
            mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
            mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
        }

        mui(".trade-list").on('tap', '.personInfo', function () {
            localStorage.setItem("person-id", $(this).attr("id"));
            dsBridge.call("goPersonInfo");

        });

    </script>

</body>

</html>